<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3//EN">
<HTML><HEAD>
<TITLE>IBM Visualization Data Explorer Programmer&#39;s Reference</TITLE>

<META HTTP-EQUIV="abstract" CONTENT="IBM Visualization Data Explorer
Programmer&#39;s Reference">
<META HTTP-EQUIV="contact" CONTENT="IBM Visualization Data Explorer
(ibmdx@watson.ibm.com)">
<META HTTP-EQUIV="owner" CONTENT="IBM Visualization Data Explorer
(ibmdx@watson.ibm.com)">
<META HTTP-EQUIV="updated" CONTENT="Tue, 16 Sep 1997 ">
<META HTTP-EQUIV="review" CONTENT="Fri, 14 Aug 1998 ">

<META HTTP-EQUIV="keywords" CONTENT="GRAPHICS VISUALIZATION VISUAL PROGRAM DATA
MINING">
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
</HEAD><BODY BGCOLOR="#FFFFFF">

<A NAME="Top_Of_Page"></A>
<H1>IBM Visualization Data Explorer Programmer&#39;s Reference</H1>
<B>&#91; <A HREF="#Bot_Of_Page">Bottom of Page</A> &#124; <A
HREF="progu025.htm">Previous Page</A> &#124; <A HREF="progu027.htm">Next
Page</A> &#124; <A HREF="../proguide.htm#ToC">Table of Contents</A> &#124; <A
HREF="progu025.htm#PToC7">Partial Table of Contents</A> &#124; <A
HREF="progu344.htm#HDRINDEX_START">Index</A> &#93;</B><HR><P>
<HR>
<H2><A NAME="HDRADDTWO" HREF="progu025.htm#PToC_58">5.2 Add2 Module Example--Add
Two Data Fields</A></H2>
<A NAME="IDX228"></A>
<A NAME="IDX229"></A>
<A NAME="IDX230"></A>
<A NAME="IDX231"></A>
<P>
This module adds together the data components of two input
Fields.
Thus, one of its functions is to ensure that the hierarchies of the
two input Objects match one-to-one.
<P>
The Add2 module takes two inputs: <TT><STRONG>field1</STRONG></TT> and
<TT><STRONG>field2</STRONG></TT>.
Each is of type <TT><STRONG>field</STRONG></TT> and has no default value.
<P>
The Add2 module has one output, <TT><STRONG>result</STRONG></TT>, of type
<TT><STRONG>field</STRONG></TT>.
<P>
<B><U>Repeat Steps (1) through (5)</U></B> of the first example (see
<A HREF="progu025.htm#HDRADDMODX">5.1 , "Add Module Example--Add a Number to
Every Data Value"</A>), using the file name
"add2" instead of "add."
Step (5) will produce files <TT>add2.c</TT>, <TT>add2.mdf</TT>, and
<TT>add2.make</TT>.
<P>
<B><U>(6) Implement the Add2 function.</U></B>
Use an editor to add the following lines after "User&#39;s code goes
here," near the end of the <TT>add2.c</TT> file:
<PRE>
   int i;
   /* first check that the lengths of the data buffers match */
   if (field1_knt != field2_knt) {
      DXSetError(ERROR_INVALID_DATA,"data components do not match");
      return 0;
   }
   for (i=0; i &lt; field1_knt; i++)
      result_data&#91;i&#93; = field1_data&#91;i&#93; + field2_data&#91;i&#93;;
   return 1;
}
</PRE>
<P>
The file <TT>/usr/local/dx/samples/program_guide/add2.c</TT> contains a
completed version of this program.
<P>
<B><U>(7) To create a version of Data Explorer that includes</U></B> the
Add2 module, enter the command:
<PRE>
make -f add2.make dxexec
</PRE>
<P>
(You have now created an executable that contains the
Add2 module.)
<P>
<B><U>(8) To invoke this version, enter&#58;</U></B>
<PRE>
dx  -mdf ./add2.mdf -exec ./dxexec
</PRE>
<P>
This command starts Data Explorer (the <TT><STRONG>add2.mdf</STRONG></TT> file
tells
the graphical user interface about Add2 and its inputs
and outputs).
The executable dxexec invoked here is the one created in Step 6.
<P>
<B><U>(9) With this version of Data Explorer</U></B> you can now run any visual
program that uses the Add2 module.
One such program is
<TT>/usr/local/dx/samples/program_guide/add2.net</TT>
<P><HR><B>&#91; <A HREF="#Top_Of_Page">Top of Page</A> &#124; <A
HREF="progu025.htm">Previous Page</A> &#124; <A HREF="progu027.htm">Next
Page</A> &#124; <A HREF="../proguide.htm#ToC">Table of Contents</A> &#124; <A
HREF="progu025.htm#PToC7">Partial Table of Contents</A> &#124; <A
HREF="progu344.htm#HDRINDEX_START">Index</A> &#93;</B> <br><b>&#91;<a
href="../allguide.htm">Data Explorer Documentation</a>&nbsp;&#124;&nbsp;<a
href="../qikguide.htm">QuickStart Guide</a>&nbsp;&#124;&nbsp;<a
href="../usrguide.htm">User&#39;s Guide</a>&nbsp;&#124;&nbsp;<a
href="../refguide.htm">User&#39;s Reference</a>&nbsp;&#124;&nbsp;<a
href="../proguide.htm">Programmer&#39;s Reference</a>&nbsp;&#124;&nbsp;<a
href="../insguide.htm">Installation and Configuration
Guide</a>&nbsp;&#93;</b><br><p><b>&#91;<a
href="http://www.research.ibm.com/dx">Data Explorer Home
Page</a>&#93;</b><p><HR ALIGN=LEFT WIDTH=600><b>&#91;<A
HREF="http://www.ibm.com/">IBM Home Page</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Orders/">Order</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Search/">Search</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Assist/">Contact IBM</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Legal/">Legal</A>&nbsp;&#93;</b><hr><p>
<A NAME="Bot_Of_Page"></A>
</BODY></HTML>
